package cn.stacey.day12;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class DemoExecutor {
	public static void main(String[] args) {
		//Executors：线程执行器
		ExecutorService service = Executors.newFixedThreadPool(3);
		service.execute(new ExecutorRunnable(8));
		service.execute(new ExecutorRunnable(9));
		service.execute(new ExecutorRunnable(10));
		service.shutdown();
	}
}

class ExecutorRunnable implements Runnable{
	private int num;
	public ExecutorRunnable(int num) {
		this.num=num;
	}
	
	@Override
	public void run() {
		while(true) {
			try {
				Thread.sleep(500);
				System.out.println(num);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
	}
	
}
